package duan.neo.com.risenumber;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    int count = 0;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        final RiseNumberTextView rnTextView = (RiseNumberTextView) findViewById(R.id.tv_num);
        findViewById(R.id.btn_up).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                count++;

                // 设置数据
                rnTextView.withNumber(2016 * count);
                // 设置动画播放时间
                rnTextView.setDuration(5000);
                // 开始播放动画
                rnTextView.start();
                // 监听动画播放结束
                rnTextView.setOnEnd(new RiseNumberTextView.EndListener() {

                    @Override
                    public void onEndFinish() {
                        Toast.makeText(MainActivity.this, "数据增长完毕...",
                                Toast.LENGTH_SHORT).show();
                    }
                });
            }
        });
    }
}
